package com.yanqu.road.server.cmd.activity.zhounianturntable;

import com.yanqu.road.pb.activity.ZhouNianTurntableProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.zhounianturntable.ZhouNianTurntableModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_ZHOUNIAN_TURNTABLE_CHOOSE_REWARD, desc = "金玉宝盘自选奖励")
public class ZhouNianTurntableChooseRewardCmd extends AbstractCommand {

    public String chooseIds;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ZhouNianTurntableProto.TurntableChooseRewardReqMsg reqMsg = ZhouNianTurntableProto.TurntableChooseRewardReqMsg.parseFrom(packet.getBytes());
        chooseIds = reqMsg.getChooseIds();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(ZhouNianTurntableModule.class).chooseReward(chooseIds);
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            ZhouNianTurntableProto.TurntableChooseRewardRespMsg.Builder respMsg = ZhouNianTurntableProto.TurntableChooseRewardRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(Protocol.U_ZHOUNIAN_TURNTABLE_CHOOSE_REWARD, respMsg);
        }
    }
}
